package com.zky.ys.test.controller;

import com.zky.ys.test.pojo.XueSheng;
import com.zky.ys.test.service.impl.XueShengServiceImpl;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (XueSheng)表控制层
 *
 * @author yangsen
 * @since 2021-06-02 11:27:31
 * @version 1.0
 */
@RestController
@RequestMapping("xueSheng")
@Api(value = "(XueSheng)管理",tags = "(XueSheng)管理接口API")
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=201,message="已创建"),
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=401,message="用户没有访问权限，需要进行身份认证"),
        @ApiResponse(code=403,message="资源不可用"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class XueShengController {
    /**
     * 服务对象
     */
    @Resource
    private XueShengServiceImpl xueShengServiceImpl;

    /**
     * 通过主键删除单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
   @RequestMapping(value = "deleteById", method = RequestMethod.POST)
   @ApiOperation(value = "根据一个主键删除一条**记录的接口",notes = "根据一个主键删除一条**记录的接口",httpMethod = "POST")
   @ApiImplicitParams({
           @ApiImplicitParam(name = "id",value = "主键",paramType = "query",dataType = "Interger",required = true),
   })
    public Map<String, Object> deleteById(@RequestParam("id") int id) {
        return this.xueShengServiceImpl.deleteById(id);
    }
    
    /**
     * 通过主键更新单条数据
     *
     * @param xueSheng 一个数据库对应的POJO数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "updateById", method = RequestMethod.POST)
    @ApiOperation(value = "通过主键更新一个**的接口",notes = "通过主键更新一个**的接口",httpMethod = "POST")
    public Map<String, Object> updateById(@RequestBody @ApiParam(name = "xueSheng",value = "pojo模型",required = true) XueSheng xueSheng) {
        return this.xueShengServiceImpl.updateById(xueSheng);
    }
    
    /**
     * 通过一个pojo对象新增单条数据
     *
     * @param xueSheng 一个数据库对应的POJO数据对象
     * @return 返回插入的主键id
     */
    @RequestMapping(value = "addOne", method = RequestMethod.POST)
    @ApiOperation(value = "根据完整记录新增一个**的接口",notes = "根据完整记录新增一个**的接口",httpMethod = "POST")
    public Map<String, Object> addOne(@RequestBody @ApiParam(name = "xueSheng",value = "pojo模型",required = true) XueSheng xueSheng) {
        return this.xueShengServiceImpl.addOne(xueSheng);
    }

}